import math


def IsPrime(number):  # 判断是否为素数
    if number == 1:
        return False
    for j in range(2, int(math.sqrt(number)) + 1):  # 从2到number的算术平方根迭代
        if number % j == 0:  # 判断j是否为number的因数
            return False
    return True

'86 71 5 41 81 79 37 89'
a = list(map(int, input("请以空格为间隔符输入任意长度的正整数：").split(" ")))
n = len(a)
for i in range(0, n - 1):
    k = i
    if IsPrime(a[k]):
        flag = True
    else:
        flag = False
    for j in range(i, n):
        if IsPrime(a[j]):
            if a[j]<a[k] or flag == False:
                k = j
                flag = True
    if k != i:
        a[k], a[i] = a[i], a[k]
    if not flag:
        continue
print(a)
